<?php
/* ----------------------------------------------------------
--               JacoCMS by Jaco Ruit                      --
-------------------------------------------------------------
--     JacoCMS is Open Source and is lincenced under       --
--             GNU General Public Licence v3               --
--          http://www.gnu.org/copyleft/gpl.html           --
-------------------------------------------------------------
--       Please don't remove any text from the footers.    --
-------------------------------------------------------------
-- Credits:   * Jaco Ruit          ~     Scripts,MySQL     --     
-----------------------------------------------------------*/

#important includes
include 'includes/config.php';
include 'includes/database.class.php'; 

#create database connection
$database = new Database();
$database->connect();

#finish includes
include 'includes/core.class.php';
include 'includes/article.class.php';
include 'includes/analytics.class.php';
include 'includes/settings.class.php';
include 'includes/page.class.php';
include 'includes/comment.class.php';

#vars, classes
$page = new Page();
$comment = new Comment();
$settings = new Settings();
$analytics = new Analytics();
$core = new Core();
$article = new Article();
$searchid = null;

#load style
$stylepath = $settings->loadStyle();
include ("style/" . $stylepath . "/styleinfo.php");

#settings
if ($settings->videoGalleryEnabled())
{
	$custom = $page->getMenuCode();
	$custom .= '<li><a href="videogallery">Video Gallery</a></li>';
}
else
{
	$custom = $page->getMenuCode();
}


#analytics
$analytics->logVisitor();

#get external id
if (isset($_GET['id']))
{
	$searchid = $core->filter($_GET['id']);
}

#check if article exists
$checkBool = $article->checkIfExists($searchid);
if ($checkBool == false)
{

	
	header ("Location: 404error");
}
else
{

#get article by id
$articlepost = array();
$articlepost = $article->getByID($searchid);
$articlehtml = $article->getHTMLCode2($articlepost);

#get comments
$articlehtml .= $comment->getByPID($searchid, "a");

#get meta tags
$metatags = $article->getMetaTags($articlepost);

#template
$smarty->assign("stylecss", $stylepath);
$smarty->assign("webname", $settings->getWebsiteName());
$smarty->assign("pagename", $articlepost['title']);
$smarty->assign("articles", $articlehtml);
$smarty->assign("headertext", $articlepost['title']);
$smarty->assign("stylename", $stylename);
$smarty->assign("styleauthor", $author);
$smarty->assign("authorwebsite", $authorwebsite);
$smarty->assign("metatags", $metatags);
$smarty->assign("custom", $custom);
$smarty->display("seoheader.tpl");
$smarty->display("menu.tpl");
$smarty->display("index.tpl");
$smarty->display("footer.tpl");
}


?>